package com.such.kit.database.bean;

import java.sql.DatabaseMetaData;
import com.such.kit.database.support.JdbcResultSetMapping;
import com.such.kit.datacast.CastCommons;

/**
 * @author SUCH
 * <pre>
 * 数据库主键元数据
 * 
 * [参考 {@link DatabaseMetaData#getPrimaryKeys(String, String, String)}]
 * </pre>
 */
public class DatabasePrimaryKey implements Comparable<DatabasePrimaryKey> {

	/** catalog：（TABLE_CAT）表所在编目 */
	@JdbcResultSetMapping("TABLE_CAT")
	private String catalog;
	/** schema：（TABLE_SCHEM）表所在模式 */
	@JdbcResultSetMapping("TABLE_SCHEM")
	private String schema;
	/** tableName：（TABLE_NAME）表名 */
	@JdbcResultSetMapping("TABLE_NAME")
	private String tableName;
	/** columnName：（COLUMN_NAME）列名 */
	@JdbcResultSetMapping("COLUMN_NAME")
	private String columnName;
	/** sequenceNumber：（KEY_SEQ）多个主键时的主键序列 */
	@JdbcResultSetMapping("KEY_SEQ")
	private String sequenceNumber;
	/** pkName：（PK_NAME）主键名 */
	@JdbcResultSetMapping("PK_NAME")
	private String pkName;

	/** [参考 {@link #catalog}] */
	public String getCatalog() {
		return this.catalog;
	}

	/** [参考 {@link #catalog}] */
	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	/** [参考 {@link #schema}] */
	public String getSchema() {
		return this.schema;
	}

	/** [参考 {@link #schema}] */
	public void setSchema(String schema) {
		this.schema = schema;
	}

	/** [参考 {@link #tableName}] */
	public String getTableName() {
		return this.tableName;
	}

	/** [参考 {@link #tableName}] */
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	/** [参考 {@link #columnName}] */
	public String getColumnName() {
		return this.columnName;
	}

	/** [参考 {@link #columnName}] */
	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	/** [参考 {@link #sequenceNumber}] */
	public String getSequenceNumber() {
		return this.sequenceNumber;
	}

	/** [参考 {@link #sequenceNumber}] */
	public void setSequenceNumber(String sequenceNumber) {
		this.sequenceNumber = sequenceNumber;
	}

	/**
	 * <pre>
	 * [参考 {@link #sequenceNumber}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setSequenceNumber(double sequenceNumber) {
		this.sequenceNumber = CastCommons.numberToString(sequenceNumber);
	}

	/**
	 * <pre>
	 * [参考 {@link #sequenceNumber}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setSequenceNumber(long sequenceNumber) {
		this.sequenceNumber = CastCommons.numberToString(sequenceNumber);
	}

	/**
	 * <pre>
	 * [参考 {@link #sequenceNumber}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setSequenceNumber(int sequenceNumber) {
		this.sequenceNumber = CastCommons.numberToString(sequenceNumber);
	}

	/**
	 * <pre>
	 * [参考 {@link #sequenceNumber}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setSequenceNumber(short sequenceNumber) {
		this.sequenceNumber = CastCommons.numberToString(sequenceNumber);
	}

	/** [参考 {@link #pkName}] */
	public String getPkName() {
		return this.pkName;
	}

	/** [参考 {@link #pkName}] */
	public void setPkName(String pkName) {
		this.pkName = pkName;
	}

	@Override
	public int compareTo(DatabasePrimaryKey o) {
		return this.getSequenceNumber().compareTo(o.getSequenceNumber());
	}

}
